home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
drawer.zip
/
EVENT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-01-04
|
2KB
|
93 lines
{$L-,D-}
unit Events;
interface
type
EventType = ( LBUTTONDOWN,
LBUTTONUP,
RBUTTONDOWN,
RBUTTONUP,
MOVE,
KEYPRESS );
Event = record
typ : EventType;
x, y : word;
ch1,
ch2 : char;
end;
procedure EnableEvents;
procedure GetEvent( var E : Event );
procedure DisableEvents;
procedure HidePointer;
procedure ShowPointer;
implementation
uses Mouse, crt;
var
ButtonMask : word;
x, y : word;
procedure EnableEvents;
var
b : word;
begin
if not ms_init( b ) then RunError(190);
ms_show;
ms_read( x, y, ButtonMask );
end;
procedure DisableEvents;
begin
ms_hide;
end;
procedure ShowPointer;
begin
ms_show;
end;
procedure HidePointer;
begin
ms_hide;
end;
procedure GetEvent( var E : Event );
label
Again;
var
NewBMask, NewX, NewY : word;
begin
Again:
ms_read( NewX, NewY, NewBMask);
E.x := NewX; E.y := NewY;
if KeyPressed then begin
E.typ := KEYPRESS;
E.ch1 := ReadKey;
if E.ch1=chr(0) then E.ch2 := ReadKey
else E.ch2 := chr(0);
end
else if (NewBMask and left_b) <> (ButtonMask and left_b) then
if (NewBMask and left_b) = left_b
then E.typ := LBUTTONDOWN
else E.typ := LBUTTONUP
else if (NewBMask and right_b) <> (ButtonMask and right_b) then
if (NewBMask and right_b) = right_b
then E.typ := RBUTTONDOWN
else E.typ := RBUTTONUP
else if (NewX<>x) or (NewY<>y) then E.typ := MOVE
else goto Again;
x := NewX;
y := NewY;
ButtonMask := NewBMask;
end;
begin
end.